﻿namespace _09_C_中深拷贝和浅拷贝的理解
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "C#的浅拷贝和深拷贝";

            Teacher teacher = new Teacher()
            {
                TeacherID = 1,
                TeacherName = "张老师",
                StudentModel = new Student()
                {
                    StudentID = 1,
                    StudentName = "张同学"
                }
            };

            Teacher cloneTeacher=teacher.Clone();
            //Teacher cloneTeacher = teacher.DeepClone();//深度拷贝

            cloneTeacher.TeacherID = 2;
            cloneTeacher.TeacherName = "小三";
            cloneTeacher.StudentModel.StudentID = 2;
            cloneTeacher.StudentModel.StudentName = "小四";

            Console.WriteLine($"teacher的数据\r\nID：{teacher.TeacherID}\r\n" +
                              $"TeacherName:{teacher.TeacherName}\r\n" +
                              $"学生信息：ID：{teacher.StudentModel.StudentID}\r\n" +
                              $"名称：{teacher.StudentModel.StudentName}");

            Console.WriteLine($"cloneteacher的数据\r\nID：{cloneTeacher.TeacherID}\r\n" +
                  $"TeacherName:{cloneTeacher.TeacherName}\r\n" +
                  $"学生信息：ID：{cloneTeacher.StudentModel.StudentID}\r\n" +
                  $"名称：{cloneTeacher.StudentModel.StudentName}");

            Console.ReadKey();
        }
    }
}
